<?php
namespace Home\Controller;

use Think\Controller;

class ReleaseController extends Controller
{

    public function release()
    {
        $ad=getAd();
        //var_dump($ad);exit();
        if(count($ad)>0){
            $this->assign("ad",$ad);
        }else{
            $ad=array(array('title'=>'<a disabled="true">暂时还没有任何广告信息！！！</a>'));
            $this->assign("ad",$ad);
        }
        
        $this->assign("ad",$ad);
        $this->display();
    }
    
    // public function releaseAdd() {
    
    // $info=M(info);
    // //print_r($info);
    // $info->select();
    // print_r( $info->select());
    // }
    public function releaseAdd()
    {
        
        // $data=array(
        // array("type"=>"$_POST[type]")
        
        // );
        
        //print_r(json_encode($_POST));exit();
        $type = $_POST['type'];
        $title = $_POST['title'];
        $content = $_POST['content'];
        $linkman = $_POST['linkman'];
        $tel = $_POST['tel'];
       
        $data = array(
            "type" => $type,
            "title" => $title,
            "content" => $content,
            "linkman" => $linkman,
            "tel" => $tel
        );
        $info=M(info);
        if ($info->add($data)){
            echo "发布成功,请耐心等待管理员审核";
            //header($string)
        }else {
            echo "发布失败";
        }
//         $json_data = json_encode($data);
//         echo $json_data;
    }
}